{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1d08e503",
   "metadata": {},
   "source": [
    "# Simple TeAAL Example\n",
    "\n",
    "This notebook tests that the fibertree and teaal depencencies are installed successfully by importing them and running a few small examples. We expect that this kernel will copy the input into the output."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fd47905f",
   "metadata": {},
   "outputs": [],
   "source": [
    "from fibertree import Tensor\n",
    "from teaal.parse import *\n",
    "from teaal.trans.hifiber import HiFiber"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ac7ca130",
   "metadata": {},
   "outputs": [],
   "source": [
    "M = 6\n",
    "N = 7\n",
    "density = 0.5\n",
    "\n",
    "# Create the tensor\n",
    "A_MN = Tensor.fromRandom(rank_ids=[\"M\", \"N\"], shape=[M, N], density=[0.9, density], seed=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8179e8c7",
   "metadata": {},
   "outputs": [],
   "source": [
    "yaml = \"\"\"\n",
    "einsum:\n",
    "    declaration:\n",
    "        A: [M, N]\n",
    "        Z: [M, N]\n",
    "    expressions:\n",
    "        - Z[m, n] = A[m, n]\n",
    "\"\"\"\n",
    "\n",
    "exec(str(HiFiber(Einsum.from_str(yaml), Mapping.from_str(yaml))), globals(), locals())\n",
    "print(\"Copied correctly:\", A_MN == Z_MN)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
